# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ucarp
pkgver=1.5.2
pkgrel=11
pkgdesc="Share common IP and do fail over"
url="https://download.pureftpd.org/ucarp/README"
arch="all"
license="ISC"
makedepends="libpcap-dev"
subpackages="$pkgname-openrc"
source="https://download.pureftpd.org/pub/ucarp/ucarp-$pkgver.tar.gz
	ucarp.initd
	ucarp.confd
	vip-up-default.sh
	vip-down-default.sh
	"
options="!check"

prepare() {
	default_prepare
	find -name config.sub | xargs chmod u+w
	update_config_sub
}

build() {
	# Workaround for gcc-10
	CFLAGS="$CFLAGS -fcommon" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-nls
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -d "$pkgdir"/etc/ucarp
	for i in vip-up-default.sh vip-down-default.sh; do
		install -m755 -D "$srcdir"/$i "$pkgdir"/etc/ucarp/$i
	done
}

sha512sums="568ff2061e59d314c72a160ccb42eb099bf7cdf04bc30f405b5b62322dff3ceb4fa037c2b430fdb4cee25f0dcacf9309a15bd814b4b70b640840400bda20b253  ucarp-1.5.2.tar.gz
3b7ed64075f3d84d40fda0f6cf0c2c19842341d34384175af94de43f94729c3f6b4ba1634a2ae35da3f1992350ea06b7d36e36038f64ef08d76c27796f7bdbd7  ucarp.initd
854b25e99896ba165919916ff31103717e539c0c3a933f451428f62a9c3eee0367787ff8deb4d582156fa4a6be620412aa98fdb615c269d178d606ac1bce818e  ucarp.confd
4db8a047c39671578d0fa0e0dfadf3ce6e4f5881a85811c5c8e986f26c97b5de64cc58578cd77ba9ee93e2c6659b178c69575d3006934da56736441c30c703ce  vip-up-default.sh
026988d259ab07568995e0609ee0b22245abcf26c65e7c3ddeea8efc801a78eb2796e7423c52731b8070db99e410db4de8217d0a3b7b8681d399fef25c64e56f  vip-down-default.sh"
